﻿@page "/Bas/Warehouse/Details"
@using nERP.ViewModel.Bas.WarehouseVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
    <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
        <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
            <Display @bind-Value="@Model.Entity.WarehouseCode" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.WarehouseName" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.Address" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.StorageFee" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.ChargePersonId" ShowLabel="true" Lookup="AllChargePersons" />
            <Display @bind-Value="@Model.Entity.Remark" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.CreateTime" ShowLabel="true" FormatString="yyyy-MM-dd HH:mm:ss" />
            <Display @bind-Value="@Model.Entity.UpdateTime" ShowLabel="true" FormatString="yyyy-MM-dd HH:mm:ss" />
            <Display @bind-Value="@Model.Entity.CreateBy" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.UpdateBy" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.IsValid" ShowLabel="true" />
        </Row>

        <div class="modal-footer table-modal-footer">
            <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]" />
        </div>

    </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private WarehouseVM Model = new WarehouseVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {


        await PostsForm(vform, "/api/Bas/Warehouse/Edit", (s) => "Sys.OprationSuccess");
    }
    public void OnClose()
    {
        CloseDialog();
    }

    private List<SelectedItem> AllChargePersons = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {


        AllChargePersons = await WtmBlazor.Api.CallItemsApi("/api/Bas/Warehouse/GetFrameworkUsers");
        AllChargePersons.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        if (id != "")
        {
            var rv = await WtmBlazor.Api.CallAPI<WarehouseVM>($"/api/Bas/Warehouse/{id}");
            Model = rv.Data;
        }

        await base.OnInitializedAsync();
    }
}
